<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学习资料区</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./lib/layui/css/layui.css" media="all">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <!--<button type="button" class="layui-btn" id="upload">
                        <i class="layui-icon">&#xe681;</i>上传文件
                    </button>-->
                    <button type="button" class="layui-btn" onclick="xadmin.open('上传文件','upload.html',600,400)">
                        <i class="layui-icon">&#xe681;</i>上传文件
                    </button>
                    <a class="layui-btn "  onclick="location.reload()" title="刷新">
                        <i class="layui-icon layui-icon-refresh"></i>刷新</a>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>文件名</th>
                            <th>种类</th>
                            <th>上传者</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <form action="/download" method="get">
                        <tr th:each="file:${session.fileList}" th:object="${file}">
                            <td th:text="*{id}"></td>
                            <td th:text="*{name}"></td>
                            <input type="hidden" name="fileName" th:value="*{name}"/>
                            <td th:text="*{type !=0} ? *{type} : |其他| "></td>
                            <td th:text="*{username}"></td>
                            <td class="td-manage">
                                <a  class="layui-btn" title="查看属性" onclick="xadmin.open('查看属性','member-edit.html',600,400)" href="javascript:;">
                                    <i class="layui-icon" >&#xe60a;</i>
                                    查看属性
                                </a>
                                <button type="submit" class="layui-btn" value="下载文件">
                                    <i class="layui-icon" >&#xe601;</i>
                                    下载文件
                                </button>
                                <a class="layui-btn layui-btn-normal" th:onclick="member_stop(this,[[*{id}]])" title="点赞" href="javascript:;">
                                    <i class="layui-icon" >&#xe6c6;</i>
                                    <span>点赞</span>
                                </a>
                            </td>
                        </tr>
                        </form>
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        <div>
                            <a class="prev" href="">&lt;&lt;</a>
                            <a class="num" href="">1</a>
                            <span class="current">2</span>
                            <a class="num" href="">3</a>
                            <a class="num" href="">489</a>
                            <a class="next" href="">&gt;&gt;</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function member_stop(obj,id){

            console.log(id);

            if($(obj).attr('title')=='点赞'){

                //发异步把用户状态进行更改
                $(obj).attr('title','取消')
                $(obj).find('i').html('&#xe6c5;');

                $(obj).find('span').html('取消');


            }else{
                $(obj).attr('title','点赞')
                $(obj).find('i').html('&#xe6c6;');

                $(obj).find('span').html('点赞');
                /*$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});*/
            }


    }
</script>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;


        // 监听全选
        form.on('checkbox(checkall)', function(data){

            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });


    });



</script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#upload' //绑定元素
            ,url: '/upload' //上传接口
            ,done: function(res){
                if (res != null) {
                    layer.msg(res.data, {icon: res.code, time: 2000});
                }else {
                    layer.msg('返回消息为空',{icon:7, time: 2000});
                }
                //上传完毕回调
            }
            ,error: function(){
                //请求异常回调
                layer.msg('未知错误',{icon:3, time: 2000});
            }
        });
    });
</script>

</html>